<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<div class="pad-lr-10">
  <form name="myform" action="?m=announce&c=admin_announce&a=listorder" method="post">
  <div class="table-list">
    <?php ?>
    <table width="100%" cellspacing="0">
      <thead>
        <tr>
          <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('gid[]');"></th>
          <th align="center"><?php echo L('title')?></th>
          <th width="150" align="center"><?php echo L('username')?></th>
          <th width="150" align="center">电话</th>
          <th width='120' align="center">IP地址</th>
          <th width='120' align="center"><?php echo L('inputtime')?></th>
          <th width="69" align="center"><?php echo L('operations_manage')?></th>
        </tr>
      </thead>
      <tbody>
        <?php
        if(is_array($data)){
          foreach($data as $guestbook){?>
          <tr>
            <td align="center"><input type="checkbox" name="gid[]" value="<?php echo $guestbook['gid']?>"></td>
            <td><?php echo $guestbook['title']?></td>
            <td align="center"><?php echo $guestbook['username']?></td>
            <td align="center"><?php echo $guestbook['phone']?></td>
            <td align="center"><?php echo $guestbook['ip']?></td>
            <td align="center" title="<?php echo date('Y-m-d H:i:s', $guestbook['addtime'])?>"><?php echo date('Y-m-d', $guestbook['addtime'])?></td>
            <td align="center">
            <a href="javascript:reply('<?php echo $guestbook['gid']?>', '<?php echo safe_replace($guestbook['title'])?>');void(0);">回复</a> |
            <a href="javascript:edit('<?php echo $guestbook['gid']?>', '<?php echo safe_replace($guestbook['title'])?>');void(0);"><?php echo L('edit')?></a>
            </td>
          </tr>
          <?php
          }
        }?>
      </tbody>
    </table>
    <div class="btn">
      <label for="check_box"><?php echo L('selected_all')?>/<?php echo L('cancel')?></label>&nbsp;
      <button type="submit" name="delete" class="button" onClick="document.myform.action='?m=guestbook&c=guestbook_admin&a=delete';return confirm('<?php echo L('affirm_delete')?>')"><?php echo L('remove_all_selected')?></button>&nbsp;
    </div>
    <div id="pages"><?php echo $this->db->pages;?></div>
  </form>
</div>
</body>
</html>
<script type="text/javascript">
// 关闭内容管理菜单
window.top.$('#display_center_id').css('display','none');

function reply(id, title){
  window.top.art.dialog({id:'reply'}).close();
  window.top.art.dialog({
    title:'回复--'+title,
    id:'reply',
    iframe:'?m=guestbook&c=guestbook_admin&a=reply&gid='+id,
    width:'700px',
    height:'500px'},
    function(){
      var d = window.top.art.dialog({id:'reply'}).data.iframe;
  	  d.document.getElementById('dosubmit').click();
      // form.click();
      return false;
    },
    function(){
      window.top.art.dialog({id:'reply'}).close();
    }
  );
}

function edit(id, title) {
	window.top.art.dialog({id:'edit'}).close();
	window.top.art.dialog({
    title:'<?php echo L('edit_announce')?>--'+title,
    id:'edit',
    iframe:'?m=guestbook&c=guestbook_admin&a=edit&gid='+id,
    width:'700px',
    height:'500px'},
    function(){
      var d = window.top.art.dialog({id:'edit'}).data.iframe;
  	  d.document.getElementById('dosubmit').click();
      return false;
    },
    function(){
      window.top.art.dialog({id:'edit'}).close();
    }
  );
}
</script>
